package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchProductionIndicators;
import com.ruoyi.system.service.IDispatchProductionIndicatorsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产指标Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchProductionIndicators")
public class DispatchProductionIndicatorsController extends BaseController
{
    @Autowired
    private IDispatchProductionIndicatorsService dispatchProductionIndicatorsService;

    /**
     * 查询生产指标列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionIndicators:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchProductionIndicators dispatchProductionIndicators)
    {
        startPage();
        List<DispatchProductionIndicators> list = dispatchProductionIndicatorsService.selectDispatchProductionIndicatorsList(dispatchProductionIndicators);
        return getDataTable(list);
    }

    /**
     * 导出生产指标列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionIndicators:export')")
    @Log(title = "生产指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchProductionIndicators dispatchProductionIndicators)
    {
        List<DispatchProductionIndicators> list = dispatchProductionIndicatorsService.selectDispatchProductionIndicatorsList(dispatchProductionIndicators);
        ExcelUtil<DispatchProductionIndicators> util = new ExcelUtil<DispatchProductionIndicators>(DispatchProductionIndicators.class);
        util.exportExcel(response, list, "生产指标数据");
    }

    /**
     * 获取生产指标详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionIndicators:query')")
    @GetMapping(value = "/{productionIndicatorsId}")
    public AjaxResult getInfo(@PathVariable("productionIndicatorsId") Long productionIndicatorsId)
    {
        return success(dispatchProductionIndicatorsService.selectDispatchProductionIndicatorsByProductionIndicatorsId(productionIndicatorsId));
    }

    /**
     * 新增生产指标
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionIndicators:add')")
    @Log(title = "生产指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchProductionIndicators dispatchProductionIndicators)
    {
        return toAjax(dispatchProductionIndicatorsService.insertDispatchProductionIndicators(dispatchProductionIndicators));
    }

    /**
     * 修改生产指标
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionIndicators:edit')")
    @Log(title = "生产指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchProductionIndicators dispatchProductionIndicators)
    {
        return toAjax(dispatchProductionIndicatorsService.updateDispatchProductionIndicators(dispatchProductionIndicators));
    }

    /**
     * 删除生产指标
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchProductionIndicators:remove')")
    @Log(title = "生产指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productionIndicatorsIds}")
    public AjaxResult remove(@PathVariable Long[] productionIndicatorsIds)
    {
        return toAjax(dispatchProductionIndicatorsService.deleteDispatchProductionIndicatorsByProductionIndicatorsIds(productionIndicatorsIds));
    }
}
